<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('出入库流水列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="btn-group-sm" id="toolbar" role="group">
            <a id="save" class="btn btn-primary btn-rounded btn-sm"><i
            ></i>&nbsp;保存数据</a>
        </div>
        <div id="div" style="height: 100%;text-align: center" class="col-sm-12 select-table striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('search:IssueReceiptFlow:edit')}]];
    var removeFlag = [[${@permission.hasPermi('search:IssueReceiptFlow:remove')}]];
    var prefix = ctx + "db/Ddjdb";
    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            // clickToSelect: true,//是否启用点击选中行
            height: $("#div").height() / 1,
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "出入库流水",
            columns: [
                // {
                //     checkbox: true,
                //
                // },
                {
                    field: 'id',
                    title: '堆垛机编码',
                    visible: true
                },
                {
                    field: 'czfs',
                    title: '操作方式'
                },
                {
                    field: 'sbzt',
                    title: '设备状态',
                    sortable: true
                },
                {
                    field: 'zxrwh',
                    title: '执行任务号',
                    visible: true
                },

                {
                    field: 'zxrwh2',
                    title: '执行任务号2'
                },
                {
                    field: 'hczt',
                    title: '货叉状态'
                },
                {
                    field: 'zxjd',
                    title: '执行阶段'
                },
                {
                    field: 'zxjd2',
                    title: '执行阶段2'
                },
                {
                    field: 'dqp',
                    title: '当前排'
                },
                {
                    field: 'dql',
                    title: '当前列'
                },
                {
                    field: 'dqc',
                    title: '当前层'
                },
                {
                    field: 'yxmbp',
                    title: '目标排'
                },
                {
                    field: 'yxmbl',
                    title: '目标列'
                },
                {
                    field: 'yxmbc',
                    title: '目标层'
                },
                {
                    field: 'rwhc',
                    title: '任务货叉'
                },
                {
                    field: 'yxxf',
                    title: '允许下发'
                },
                {
                    field: 'xtxh',
                    title: '心跳信号'
                }, {
                    field: 'qcrw',
                    title: '清除任务'
                }, {
                    field: 'fhrwh',
                    title: '放货任务号'
                }, {
                    field: 'dqxd',
                    title: '当前巷道'
                },

            ],
            onClickCell: function (field, value, row, $element) {
                $element.attr('contenteditable', true);
                $element.blur(function () {
                    let tdValue = $element.html();
                    tdValue=tdValue.replace(/<br>/g, "")
                    switch (field) {
                        case "id":
                            row.id = tdValue;
                            break;
                        case "czfs":
                            row.czfs = tdValue;
                            break;
                        case "sbzt":
                            row.sbzt = tdValue;
                            break;
                        case "zxrwh":
                            row.zxrwh = tdValue;
                            break;
                        case "zxrwh2":
                            row.zxrwh2 = tdValue;
                            break;
                        case "hczt":
                            row.hczt = tdValue;
                            break;
                        case "zxjd":
                            row.zxjd = tdValue;
                            break;
                        case "zxjd2":
                            row.zxjd2 = tdValue;
                            break;
                        case "dqp":
                            row.dqp = tdValue;
                            break;
                        case "dql":
                            row.dql = tdValue;
                            break;
                        case "dqc":
                            row.dqc = tdValue;
                            break;
                        case "yxmbp":
                            row.yxmbp = tdValue;
                            break;
                        case "yxmbl":
                            row.yxmbl = tdValue;
                            break;
                        case "yxmbc":
                            row.yxmbc = tdValue;
                            break;
                        case "rwhc":
                            row.rwhc = tdValue;
                            break;
                        case "yxxf":
                            row.yxxf = tdValue;
                            break;
                        case "xtxh":
                            row.xtxh = tdValue;
                            break;
                        case "qcrw":
                            row.qcrw = tdValue;
                            break;
                        case "fhrwh":
                            row.fhrwh = tdValue;
                            break;
                        case "dqxd":
                            row.dqxd = tdValue;
                            break;
                    }
                })


            }
        };
        $.table.init(options);
    });

    $("#save").click(function () {
        var data = $("#bootstrap-table").bootstrapTable('getData');

        for (let i = 0; i < data.length; i++) {
            var shuju = "Ddjdb/edit?ID=" + data[i].id + "&CZFS=" + data[i].czfs + "&SBZT=" + data[i].sbzt + "&ZXRWH=" +
                data[i].zxrwh + "&ZXRWH2=" + data[i].zxrwh2 + "&HCZT=" + data[i].hczt + "&ZXJD=" + data[i].zxjd + "&ZXJD2=" +
                data[i].zxjd2 + "&DQP=" + data[i].dqp + "&DQL=" + data[i].dql + "&DQC=" + data[i].dqc + "&YXMBP=" +
                data[i].yxmbp + "&YXMBL=" + data[i].yxmbl + "&YXMBC=" + data[i].yxmbc + "&RWHC=" + data[i].rwhc + "&YXXF=" +
                data[i].yxxf + "&XTXH=" + data[i].xtxh + "&QCRW=" + data[i].qcrw + "&FHRWH=" + data[i].fhrwh + "&DQXD=" + data[i].dqxd
            console.log(shuju)
            $.ajax({
                url: shuju,       //后台地址
                contentType: 'application/json',
                type: 'post',
                // data: JSON.stringify(info),
                dataType: 'json',
                success: function callbackss(data) {
                    location.reload()

                }
            })
        }
    })
</script>
</body>
</html>